
#include <string>
using namespace std;
class Solution {
public:
    string addStrings(string num1, string num2) {
        int end1 = num1.size() - 1, end2 = num2.size() - 1;
        int carry = 0;
        int ret = 0;
        string retNum;
        while (end1 >= 0 || end2 >= 0) {
            int val1 = end1 < 0 ? 0 : num1[end1] - '0';
            int val2 = end2 < 0 ? 0 : num2[end2] - '0';

            //int val1 = end1 >= 0 ? num1[end1] - '0' : 0;
            //int val2 = end2 >= 0 ? num2[end2] - '0' : 0;

            int ret = val1 + val2 + carry;

            carry = ret / 10;
            ret = ret % 10;

            retNum += (ret + '0');
            end1--;
            end2--;
        }
        if (carry == 1) {
            retNum += '1';
        }
        reverse(retNum.begin(), retNum.end());
        return retNum;
    }
};

class Solution {
public:
    void reverseString(vector<char>& s) {
        //reverse(s.begin(),s.end());
        //int n = s.size();
        int left = 0;
        int right = s.size() - 1;
        while (left < right)
        {
            swap(s[left], s[right]);
            left++;
            right--;
        }
    }
};